//
//  DiseaseTypeView.m
//  QuickCure
//
//  Created by 王震 on 16/9/12.
//  Copyright © 2016年 haoge. All rights reserved.
//

#import "DiseaseTypeView.h"
#import <Masonry.h>
#import "TypeView.h"

@interface DiseaseTypeView ()

@property(nonatomic,strong) UIImageView *headImageView;
@property(nonatomic,strong) UILabel *headLabel;
@property(nonatomic,strong) TypeView *typeScrollView;

@end

@implementation DiseaseTypeView

-(instancetype)init{
    
    if (self = [super init]) {
        //创建子控件
        [self addSubViews];
        
        //设置子控件的frame
        [self setSubViewsFrame];
        
        //设置子控件的数据内容
        [self setSubViewsData];
    }
    return self;
}

#pragma mark - 创建子控件
-(void)addSubViews{
    
    [self addSubview:self.headImageView];
    [self addSubview:self.headLabel];
    [self addSubview:self.typeScrollView];
}

#pragma mark - 设置子控件frame
-(void)setSubViewsFrame{
    
    [self.headImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(10);
        make.leading.equalTo(self).offset(15);
        make.height.equalTo(@(30));
        make.width.equalTo(@(10));
    }];
    
    [self.headLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.headImageView);
        make.leading.equalTo(self.headImageView.mas_trailing).offset(15);
    }];
    
    [self.typeScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.headImageView.mas_bottom).offset(10);
        make.leading.and.trailing.and.bottom.equalTo(self);
    }];
    
}

#pragma mark - 设置子控件数据及显示内容
-(void)setSubViewsData{
    
    self.headImageView.image = [UIImage imageNamed:@"yj"];
    
    [self.headLabel setText:@"名医通"];
    [self.headLabel setFont:[UIFont systemFontOfSize:21]];
    
}

#pragma mark - 控件的懒加载
-(TypeView *)typeScrollView{
    if (nil == _typeScrollView) {
        _typeScrollView = [[TypeView alloc] init];
    }
    return _typeScrollView;
}

-(UIImageView *)headImageView{
    if (nil == _headImageView) {
        _headImageView = [[UIImageView alloc] init];
    }
    return _headImageView;
}
-(UILabel *)headLabel{
    if (nil == _headLabel) {
        _headLabel = [[UILabel alloc] init];
    }
    return _headLabel;
}
@end
